#ifndef _X_TIME_H
#define _X_TIME_H
#include "xDef.h"
#include <sys/time.h>
#include <chrono>
#include <iostream>
namespace xNet
{
    namespace xTime
    {
        static uint64 GetCurTime()
        {
            struct timeval tv;
            gettimeofday(&tv,NULL);
            return tv.tv_sec;
        }
        static uint64 GetCurTimeMs()
        {
            struct timeval tv;
            gettimeofday(&tv,NULL);
            return tv.tv_sec*1000 + tv.tv_usec/1000;
        }
        static uint64 GetCurTimeUs()
        {
            struct timeval tv;
            gettimeofday(&tv,NULL);
            return tv.tv_sec*1000000 + tv.tv_usec;
        }
        static uint64 GetCurDaily0Clock()
        {
            time_t t = time(NULL);
            struct tm * tm= localtime(&t);
            tm->tm_hour = 0;
            tm->tm_min = 0;
            tm->tm_sec = 0;
            return  mktime(tm);
        }
        static uint64 GetCurDaily24Clock()
        {
            time_t t = time(NULL);
            struct tm * tm= localtime(&t);
            tm->tm_hour = 23;
            tm->tm_min = 59;
            tm->tm_sec = 59;
            return  mktime(tm);
        }
    }
}

#endif